/**
 * CalendarSeeker class
 *
 * @author sergei
 *
 * @date 24 Jan 2013
 */


import java.util.*;

/*
 * Enum class responding for transformation of numbers to days of week.
 */
enum DaysOfWeek {
    SUNDAY(0), MONDAY(1), TUESDAY(2), WENDESDAY(3), 
    THURSDAY(4), FRIDAY(5), SATURDAY(6);

    private int dayValue;
    
    /**
     * Constructor with parameter to current enum class.
     * @param dayValue Numerical value of a day of week.
     */
    DaysOfWeek(int dayValue) {
        this.dayValue = dayValue;
    }
    
    /**
     * Returns numerical value for day of week.
     */
    protected int getDayValue() {
        return this.dayValue;
    }
    
    /**
     * Method getDayByInt transforms int value into a dayname.
     * @param dayValue int value of a day of week.
     * @return DaysOfWeek element, which represents input number.
     * @throws IllegalArgumentException if gained wrong daynumber 
     * (not from 0 to 6).
     */
    public static DaysOfWeek getDayByInt(int dayValue) 
            throws IllegalArgumentException{
        for (DaysOfWeek day : DaysOfWeek.values()) {
            if (day.getDayValue() == dayValue) {
                return day;
            }
        }
        throw new IllegalArgumentException("Wrong input data!");
    }
}

public class CalendarSeeker{
    /**
     * Method inputDates returns size of the array that user will
     * input after.
     * @result Size of the array to be created.
     * @throws IllegalArgumentException if entered wrong data.
     */
    private static int[] inputDates() 
            throws IllegalArgumentException {
	    Scanner scanner = new Scanner(System.in);
        int day;
	    int month;
		int year;
        
        System.out.print("Input day:");
        day = scanner.nextInt();
        System.out.print("Input month:");
        month = scanner.nextInt();
        System.out.print("Input year:");
        year = scanner.nextInt();
        /* Checking if input data is correct */
	    if ((day <= 0) || (day > 31) ||
            (month <=0) || (month > 12) ||
            (year <=0)) {
            throw new IllegalArgumentException("Wrong value!");
        }

	    return new int[] {day,month,year};
    }

    /**
     * Method findDayOfWeekIndex returns number in range of 7, that represents 
     * exact day of week.
     * @param int[] date Array of 3 elements, 0 - day, 1 - month, 2 - year
     * @return int       Index of day of the week.
     */
    private static int findDayOfWeekIndex(int[] date) {
        int a = (14 - date[1]) / 12;
        int y = (date[2] - a);
        int m = date[1] + 12 * a - 2;
        
		return (7000 + (date[0] + y + (y / 4) - (y / 100) 
                                + (y / 400) + (31 * m) / 12)) % 7;
    }

	public static void main (String []args) {
			int[] date;
            date = CalendarSeeker.inputDates();
            
            int dayValue;
            dayValue = findDayOfWeekIndex(date);

            System.out.println(DaysOfWeek.getDayByInt(dayValue));
    }
}
